package com.lnsf.bookstore.web.comment.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.web.comment.dao.ApiCommentMapper;
import com.lnsf.bookstore.web.comment.service.ApiCommentService;
import com.lnsf.bookstore.web.comment.vo.ApiComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ApiCommentServiceImpl implements ApiCommentService {

    @Autowired
    private ApiCommentMapper apiCommentMapper;

    @Override
    public void save(List<ApiComment> list) {
        apiCommentMapper.saveBatch(list);
    }

    @Override
    public Map queryTotal(Map<String, Object> map) {
        return apiCommentMapper.queryTotal4Map(map);
    }

    @Override
    public PageInfo<ApiComment> getPage(Map<String, Object> map) {
        PageHelper.startPage(Integer.parseInt(map.get("page").toString()),Integer.parseInt(map.get("limit").toString()));
        return new PageInfo<ApiComment>(apiCommentMapper.queryList(map));
    }
}
